cmake_minimum_required(VERSION 3.5)
project(ProtoBufDemo)

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)

# 设置 C++ 标准
set(CMAKE_CXX_STANDARD 11)

# 查找 Protobuf 库
find_package(Protobuf REQUIRED)

# 生成对应的 C++ 文件
protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS message.proto)

# 添加可执行文件
add_executable(proto_demo main.cpp ${PROTO_SRCS})

# 链接 Protobuf 库
target_link_libraries(proto_demo ${Protobuf_LIBRARIES})

# cmake_minimum_required(VERSION 3.22.0)
# project(ProtoBufDemo)

# # 设置 C++ 标准
# set(CMAKE_CXX_STANDARD 11)

# # 查找 Protobuf 库
# find_package(Protobuf REQUIRED)

# # 生成对应的 C++ 文件
# protobuf_generate_cpp(PROTO_SRCS PROTO_HDRS message.proto)